package Demo3;

/*
 *Description:
 *User:laoHu
 *Created with Intellij IDEA 2025
 *Data:2025.05.00
 *Time:00:00
 */
public class Computer{

    public void powerOn(){
        System.out.println("打开电脑.....");
    }

    public void powerOff(){
        System.out.println("关闭电脑....");
    }

    //6.接口可以使用向上转型和动态绑定或向下转型
    public void useComputer(USB usb){
     usb.open();
        if(usb instanceof KeyBoard){
            KeyBoard keyBoard = (KeyBoard) usb;
            keyBoard.useKeyBoard();
        }else if(usb instanceof IMouse){
          IMouse iMouse = (IMouse) usb;
          iMouse.click();
        }
        usb.close();
    }
}
